package com.atguigu.gulimall.product.service.impl;

import com.atguigu.gulimall.product.entity.MordersEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.gulimall.product.dao.McarouselDao;
import com.atguigu.gulimall.product.entity.McarouselEntity;
import com.atguigu.gulimall.product.service.McarouselService;
import org.springframework.util.StringUtils;


@Service("mcarouselService")
public class McarouselServiceImpl extends ServiceImpl<McarouselDao, McarouselEntity> implements McarouselService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        QueryWrapper<McarouselEntity> mcarouselEntityQueryWrapper = new QueryWrapper<McarouselEntity>();
        if(!StringUtils.isEmpty(key)){
            mcarouselEntityQueryWrapper.eq("carousel_id",key).or().like("describes",key);
        }

        IPage<McarouselEntity> page = this.page(
                new Query<McarouselEntity>().getPage(params),
                new QueryWrapper<McarouselEntity>()
        );
        return new PageUtils(page);
    }

}